package com.atguigu.map;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * @program: IDEAcode
 * @description:
 * @author: Mr.zjx
 * create: 2021-08-03-15-59
 **/
public class MapIteartorTest {
    public static void main(String[] args) {
        //创建Map集合，键是字符串，值是整数
        Map<String,Integer> map = new HashMap<String,Integer>();
        map.put("c++",15000);
        map.put("java",14000);
        map.put("UI",12000);
        map.put("php",13000);
        Set<String> set = map.keySet();
       /* //迭代器遍历set集合，取出元素
        Iterator<String> it = set.iterator();
        while (it.hasNext()){
            String key = it.next();//键
            Integer value = map.get(key);//键找值
            System.out.println(key+"="+value);
        }*/
       //keySet()获取
       for (String key : set){
           Integer value = map.get(key);
           System.out.println(key+"="+value);
       }
    }
}
